import request from '@/utils/request'
import { makeFormData } from '@/utils/util'

const clueApi = {
  inquire: 'crm/web/leads/page', // 查询线索
  add: 'crm/web/leads/add', // 新增线索
  edit: 'crm/web/leads/updateById', // 编辑
  info: 'crm/web/leads/detail_with_clientele', // 详情
  follow: 'crm/web/leadsHistory/add', // 新增更加记录
  transfer: 'crm/web/leads/update_leads_staff', // 移交
  editState: 'crm/web/leads/updateStatusById' // 放弃and 成交
}

export function addSubmit (data = {}) {
  return request({
    url: clueApi.add,
    method: 'post',
    data: makeFormData(data)
  })
}

export function updataSubmit (data = {}) {
  return request({
    url: clueApi.add,
    method: 'post',
    data: makeFormData(data)
  })
}

export function Submit (data = {}) {
  return request({
    url: clueApi.inquire,
    method: 'post',
    data: makeFormData(data)
  })
}

export function getClueInfo (params = {}) {
  return request({
    url: clueApi.info,
    method: 'post',
    params
  })
}

export function clueFollow (data = {}) {
  return request({
    url: clueApi.follow,
    method: 'post',
    data: makeFormData(data)
  })
}

export function clueTransfer (data = {}) {
  return request({
    url: clueApi.transfer,
    method: 'post',
    data: makeFormData(data)
  })
}

export function updateState (data = {}) {
  return request({
    url: clueApi.editState,
    method: 'post',
    data: makeFormData(data)
  })
}
